import {
  BaseEntity,
  Column,
  CreateDateColumn,
  DeleteDateColumn,
  Entity,
  ManyToOne,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';
import { Mercadosku } from './mercadosku.entity';
import { Mercadoproduct } from './mercadoproduct.entity';
import { Warehouse } from './warehouse.entity';
import { Inventoryplan } from './inventoryplan.entity';
import { Outboundplan } from './outboundplan.entity';

@Entity()
export class Box extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    comment: '箱号',
    nullable: false,
    unique: true,
    default: null,
    type: 'varchar',
  })
  name: string;

  @Column({
    comment: '唛头图片',
    nullable: true,
    unique: false,
    default: null,
    type: 'varchar',
  })
  maitouImage: string;

  @Column({
    comment: '运单号',
    nullable: true,
    unique: false,
    default: null,
    type: 'varchar',
  })
  mercadoBoxNumber: string;

  @Column({
    comment: '装箱个数',
    nullable: false,
    unique: false,
    default: 0,
    type: 'int',
  })
  boxNumber: number;

  @Column({
    comment: '状态',
    nullable: false,
    unique: false,
    default: 0,
    type: 'int',
  })
  status: number;
  //状态 0：运输中 1：已入库 2: 已加入出库计划 3.已出库

  @Column({
    comment: '重量（kg）',
    nullable: true,
    unique: false,
    default: 0,
    type: 'decimal',
    precision: 10,
    scale: 2,
  })
  weight: number;

  @Column({
    comment: '宽度（cm）',
    nullable: true,
    unique: false,
    default: 0,
    type: 'decimal',
    precision: 10,
    scale: 2,
  })
  width: number;

  @Column({
    comment: '高度（cm）',
    nullable: true,
    unique: false,
    default: 0,
    type: 'decimal',
    precision: 10,
    scale: 2,
  })
  height: number;

  @Column({
    comment: '长度（cm）',
    nullable: true,
    unique: false,
    default: 0,
    type: 'decimal',
    precision: 10,
    scale: 2,
  })
  long: number;

  // 到货时间
  @Column({ comment: '到货时间', nullable: true, unique: false, default: null })
  arrivalTime: Date;
  // 支付时间
  @Column({ comment: '支付时间', nullable: true, unique: false, default: null })
  payTime: Date;

  @Column({ comment: '是否支付', nullable: true, unique: false, default: null })
  isPay: number;

  @ManyToOne(() => Mercadosku, (mercadosku) => mercadosku.boxs)
  mercadosku: Mercadosku;

  @ManyToOne(() => Mercadoproduct, (mercadoproduct) => mercadoproduct.boxs)
  mercadoproduct: Mercadoproduct;

  @ManyToOne(() => Warehouse, (warehouse) => warehouse.boxs)
  warehouse: Warehouse;

  @ManyToOne(() => Inventoryplan, (inventoryplan) => inventoryplan.boxs)
  inventoryplan: Inventoryplan;

  @ManyToOne(() => Outboundplan, (outboundplan) => outboundplan.boxs)
  outboundplan: Outboundplan;

  @CreateDateColumn()
  createTime: Date;

  @UpdateDateColumn()
  updateTime: Date;

  @DeleteDateColumn({ nullable: true })
  deleteTime: Date;
}
